package com.demo.apparel.mapper.uniapp;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.demo.apparel.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrdersMapper extends BaseMapper<Orders> {


    // 根据用户ID查询用户的所有订单
    List<Orders> selectByUserId(String userId);

    // 根据订单ID查询订单
    Orders selectById(String orderId);

    @Select("SELECT * FROM orders WHERE status = 'UNPAID' AND created_time < #{expiryTime}")
    List<Orders> selectUnpaidOrdersOlderThan(@Param("expiryTime") LocalDateTime expiryTime);

}